﻿using DocumentFormat.OpenXml.Lite.Shared;
using DocumentFormat.OpenXml.Lite.Xml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace DocumentFormat.OpenXml.Lite.DrawingML.Chart.Elements
{
    [XmlRoot("cat", Namespace = Constants.Chart)]
    public class Category : XmlSerializable
    {
        [XmlElement("", Namespace = Constants.Chart)]
        public ICategoryElement Element { get; set; }

        public Category() { }
    }

    [XmlRoot("multiLvlStrRef", Namespace = Constants.Chart)]
    public class MultiLevelStringReference : XmlSerializable, ICategoryElement
    {
        [XmlElement("f", Namespace = Constants.Chart)]
        public SimpleText Formula { get; set; }

        [Optional]
        [XmlElement("multiLvlStrCache", Namespace = Constants.Chart)]
        public MLStringCache MultiLevelStringCache { get; set; }

        [Optional]
        [XmlElement("extLst", Namespace = Constants.Chart)]
        public ExtensionList ExtensionList { get; set; }

        public MultiLevelStringReference() { }
    }

    [XmlRoot("strRef", Namespace = Constants.Chart)]
    public class StringReference : XmlSerializable, ICategoryElement, IChartTextElement
    {
        [XmlElement("f", Namespace = Constants.Chart)]
        public SimpleText Formula { get; set; }

        [Optional]
        [XmlElement("strCache", Namespace = Constants.Chart)]
        public StringLiteral NumberCache { get; set; }

        [Optional]
        [XmlElement("extLst", Namespace = Constants.Chart)]
        public ExtensionList ExtensionList { get; set; }

        public StringReference() { }
    }

    [XmlRoot("strLit", Namespace = Constants.Chart)]
    public class StringLiteral : XmlSerializable, ICategoryElement
    {
        [Optional]
        [XmlElement("ptCount", Namespace = Constants.Chart)]
        public RequiredValue<uint> PointCount { get; set; }

        [Optional]
        [XmlElement("pt", Namespace = Constants.Chart)]
        public XmlList<Point> Points { get; set; }

        [Optional]
        [XmlElement("extLst", Namespace = Constants.Chart)]
        public ExtensionList ExtensionList { get; set; }

        public StringLiteral()
        {
            Points = new XmlList<Point>();
        }
    }

    [XmlRoot("multiLvlStrCache", Namespace = Constants.Chart)]
    public class MLStringCache : XmlSerializable
    {
        [Optional]
        [XmlElement("ptCount", Namespace = Constants.Chart)]
        public RequiredValue<uint> PointCount { get; set; }

        [Optional]
        [XmlElement("lvl", Namespace = Constants.Chart)]
        public XmlList<Level> Levels { get; set; }

        [Optional]
        [XmlElement("extLst", Namespace = Constants.Chart)]
        public ExtensionList ExtensionList { get; set; }

        public MLStringCache()
        {
            Levels = new XmlList<Level>();
        }
    }

    [XmlRoot("lvl", Namespace = Constants.Chart)]
    public class Level : XmlSerializable
    {
        [Optional]
        [XmlElement("pt", Namespace = Constants.Chart)]
        public XmlList<Point> Points { get; set; }

        public Level()
        {
            Points = new XmlList<Point>();
        }
    }
}
